package com.bawei.module_car_space.ui

import com.bawei.module_car_space.http.SpaceApi
import com.bawei.module_car_space.http.SpaceNetModel
import com.bawei.module_car_space.model.EditModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import javax.inject.Inject

class SpaceRepository @Inject constructor() {

    @Inject
    @SpaceNetModel.CommonMainApi
    lateinit var spaceApi: SpaceApi

    //列表
    fun getSpace(spaceType: String) = flow {
        emit(spaceApi.getSpaceData(spaceType))
    }.flowOn(Dispatchers.IO)

    fun addSpace(editModel: EditModel) = flow {
        emit(spaceApi.addSpaceData(editModel))
    }.flowOn(Dispatchers.IO)

}